﻿using System;
using System.Collections.Generic;
using System.Windows.Forms;
using DemoValidate.Properties;

namespace DemoValidate
{
    public partial class CheckForm : Form
    {
        private readonly ValidateHighlight _validateHighlight;
        public Boolean CheckC04 = false;
        public CheckForm()
        {
            InitializeComponent();
            _validateHighlight = new ValidateHighlight();
        }

        private void btnghi_Click(object sender, System.EventArgs e)
        {
            var list = new Dictionary<TextBox, InputType>
            {
                {txthonten, InputType.ChuoiRong},
                {txtTuoi, InputType.SoNguyenDuong},
                {txtNamsinh, InputType.NgayThang},
                {txtLuong, InputType.SoThucDuong},
            };

            var master = !_validateHighlight.TextBox(list);
            if (master)
            {
                MessageBox.Show(Resources.msgGhiThanhCong);
            }
            else
            {
                MessageBox.Show(Resources.msgKhongthahconh);
            }
            var a = _validateHighlight.CheckTextbox(txthonten, InputType.ChuoiRong);
            if (!_validateHighlight.CheckTextbox(txthonten, InputType.ChuoiRong).Result)
            {
                lbHoTen.Text = _validateHighlight.CheckTextbox(txthonten, InputType.ChuoiRong).MsgError;
            }
            else if (!_validateHighlight.CheckTextbox(txtTuoi, InputType.SoNguyenDuong).Result)
            {
                lbTuoi.Text = _validateHighlight.CheckTextbox(txtTuoi, InputType.ChuoiRong).MsgError;
            }
        }
    }
}
